package com.villaday.idf.activity;

import com.google.android.material.tabs.TabLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import androidx.appcompat.widget.Toolbar;
import android.view.View;

import com.villaday.idf.R;
import com.villaday.idf.base.BaseActivity;
import com.villaday.idf.custom.CustomScrollViewPager;
import com.villaday.idf.fragment.MyOrderFragment;
import com.villaday.idf.util.ToolBarUtil;

import butterknife.BindView;

/*
* 我的订单
* */
public class MyOrderActivity extends BaseActivity {


    @BindView(R.id.toolbar_text)
    Toolbar toolbarText;
    @BindView(R.id.tab)
    TabLayout tab;
    @BindView(R.id.vp)
    CustomScrollViewPager vp;

    @Override
    protected int getViewResId() {
        return R.layout.activity_my_order;
    }

    @Override
    protected void init() {
        ToolBarUtil.initToolBar(toolbarText, "我的订单", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onBackPressed();
            }
        });

        final String[] titles = {"全部", "待支付", "待使用", "已完成", "取消/退款"};
        vp.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                return MyOrderFragment.instance(position);
            }

            @Override
            public int getCount() {
                return titles.length;
            }

            @Override
            public CharSequence getPageTitle(int position) {
                return titles[position];
            }
        });
        tab.setupWithViewPager(vp);
    }
}
